package com.hc.sensitive.factory;

import com.hc.sensitive.dao.SensitiveWordDao;
import com.hc.sensitive.domain.SensitiveWord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 数据库中获取敏感词列表
 */
@Component
public class MysqlWordFactory implements IWordFactory {
    @Autowired
    private SensitiveWordDao sensitiveWordDao;


    @Override
    public List<String> getWordList() {
        return sensitiveWordDao.list()
                .stream()
                .map(SensitiveWord::getWord)
                .collect(Collectors.toList());
    }
}
